package com.taoding.entity.base;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import com.taoding.util.BosUtils;

import java.io.Serializable;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * <p>
 * 系统用户
 * </p>
 *
 * @author lxh123
 * @since 2019-12-04
 */
public class User extends Model<User> {

    private static final long serialVersionUID = 1L;

    private String id;
    @TableField("corp_id")
    private String corpId;
    @TableField("create_time")
    private String createTime;
    @TableField("create_user")
    private String createUser;
    @TableField("create_user_id")
    private String createUserId;
    @TableField("is_delete")
    private Integer isDelete;
    private Date timestamp;
    @TableField("update_time")
    private String updateTime;
    @TableField("update_user")
    private String updateUser;
    @TableField("update_user_id")
    private String updateUserId;
    private String avatar;
    @TableField("customer_id")
    private String customerId;
    private String flag;
    @TableField("is_admin")
    private String isAdmin;
    @TableField("is_manager")
    private Integer isManager;
    private String name;
    @TableField("open_id")
    private String openId;
    private String password;
    private String phone;
    private String post;
    private String username;
    @TableField("work_unit")
    private String workUnit;


    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getCorpId() {
        return corpId;
    }

    public void setCorpId(String corpId) {
        this.corpId = corpId;
    }

    public String getCreateTime() {
        return createTime;
    }

    public void setCreateTime(String createTime) {
        this.createTime = createTime;
    }

    public String getCreateUser() {
        return createUser;
    }

    public void setCreateUser(String createUser) {
        this.createUser = createUser;
    }

    public String getCreateUserId() {
        return createUserId;
    }

    public void setCreateUserId(String createUserId) {
        this.createUserId = createUserId;
    }

    public Integer getIsDelete() {
        return isDelete;
    }

    public void setIsDelete(Integer isDelete) {
        this.isDelete = isDelete;
    }

    public Date getTimestamp() {
        return timestamp;
    }

    public void setTimestamp(Date timestamp) {
        this.timestamp = timestamp;
    }

    public String getUpdateTime() {
        return updateTime;
    }

    public void setUpdateTime(String updateTime) {
        this.updateTime = updateTime;
    }

    public String getUpdateUser() {
        return updateUser;
    }

    public void setUpdateUser(String updateUser) {
        this.updateUser = updateUser;
    }

    public String getUpdateUserId() {
        return updateUserId;
    }

    public void setUpdateUserId(String updateUserId) {
        this.updateUserId = updateUserId;
    }

    public String getAvatar() {
        return avatar;
    }

    public void setAvatar(String avatar) {
        this.avatar = avatar;
    }

    public String getCustomerId() {
        return customerId;
    }

    public void setCustomerId(String customerId) {
        this.customerId = customerId;
    }

    public String getFlag() {
        return flag;
    }

    public void setFlag(String flag) {
        this.flag = flag;
    }

    public String getIsAdmin() {
        return isAdmin;
    }

    public void setIsAdmin(String isAdmin) {
        this.isAdmin = isAdmin;
    }

    public Integer getIsManager() {
        return isManager;
    }

    public void setIsManager(Integer isManager) {
        this.isManager = isManager;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getOpenId() {
        return openId;
    }

    public void setOpenId(String openId) {
        this.openId = openId;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getPhone() {
        return phone;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }

    public String getPost() {
        return post;
    }

    public void setPost(String post) {
        this.post = post;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getWorkUnit() {
        return workUnit;
    }

    public void setWorkUnit(String workUnit) {
        this.workUnit = workUnit;
    }

    @Override
    protected Serializable pkVal() {
        return this.id;
    }


    /**
     * 获取头像照片Url
     * @return
     */
    public String getAvatarUrl(){
        if(StringUtils.isNotEmpty(this.avatar)){
            return BosUtils.getUrlByBosKey(this.avatar);
        }
        return null;
    }

    /**
     * 角色ids的集合
     */
    @TableField(exist = false)
    private List<String> roleIdList = new ArrayList<String>();

    /**
     * 角色名称（展示用）
     */
    @TableField(exist = false)
    private List<String> roleNameList = new ArrayList<String>();

    /**
     * 角色code
     */
    @TableField(exist = false)
    private List<String> roleCodeList = new ArrayList<String>();


    public List<String> getRoleIdList() {
        return roleIdList;
    }

    public void setRoleIdList(List<String> roleIdList) {
        this.roleIdList = roleIdList;
    }

    public List<String> getRoleNameList() {
        return roleNameList;
    }

    public void setRoleNameList(List<String> roleNameList) {
        this.roleNameList = roleNameList;
    }

    public List<String> getRoleCodeList() {
        return roleCodeList;
    }

    public void setRoleCodeList(List<String> roleCodeList) {
        this.roleCodeList = roleCodeList;
    }

    @Override
    public String toString() {
        return "User{" +
        ", id=" + id +
        ", corpId=" + corpId +
        ", createTime=" + createTime +
        ", createUser=" + createUser +
        ", createUserId=" + createUserId +
        ", isDelete=" + isDelete +
        ", timestamp=" + timestamp +
        ", updateTime=" + updateTime +
        ", updateUser=" + updateUser +
        ", updateUserId=" + updateUserId +
        ", avatar=" + avatar +
        ", customerId=" + customerId +
        ", flag=" + flag +
        ", isAdmin=" + isAdmin +
        ", isManager=" + isManager +
        ", name=" + name +
        ", openId=" + openId +
        ", password=" + password +
        ", phone=" + phone +
        ", post=" + post +
        ", username=" + username +
        ", workUnit=" + workUnit +
        "}";
    }
}
